#include <bits/stdc++.h>
using namespace std;
const int maxn =5e2+10;
int A[maxn];
pair<int, int> P[maxn];
vector<int> ans;
void change(int p){
    swap(A[p+1], A[p+2]);
    swap(A[p], A[p+1]);
    ans.push_back(p);
}
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T; cin >> T;
    while(T--){
        int N; cin >> N;
        for (int i = 1; i <= N; ++i) {
            cin >> A[i];
            P[i] = {A[i], i};
        }
        sort(P+1, P+N+1);

        for (int i = 1; i <= N; ++i) {
            auto p = P[i];
            A[p.second] = i;
        }
        int inver = 0;
        for (int i = 1; i <= N-1; ++i) {
            for (int j = i+1; j <= N; ++j) {
                if(A[i] > A[j]) ++inver;
            }
        }
        bool flg = true;
        if(inver%2){
            flg = false;
            for (int i = 1; i <= N-1; ++i) {
                if(P[i].first == P[i+1].first){
                    flg = true;
                    swap(A[P[i].second], A[P[i+1].second]);
                    break;
                }
            }
        }
        if(!flg) {cout << -1 << "\n"; continue;}
        ans.clear();
        for (int i = 1; i <= N; ++i) {
            int p = find(A+i, A+1+N, i)-A;
            while(p-i >= 2){
                change(p-2);
                p-=2;
            }
            if(p == i) continue;
            change(p-1), change(p-1);
        }
        cout << ans.size() << "\n";
        for (int i = 0; i < ans.size(); ++i) {
            if(i) cout << ' ';
            cout << ans[i];
        }
        cout << "\n";
    }
    return 0;
}